{template 'common/header'}
<script language="JavaScript" src="{MODULE_URL}template/public/js/delete.js"></script>
<ol class="breadcrumb we7-breadcrumb">
    <a href="{php echo $this->createWebUrl('talk',array('type'=>'0'));}"><i class="wi wi-back-circle"></i> </a>
    <li>
        <a href="{php echo $this->createWebUrl('talk',array('type'=>'1'));}">话题列表</a>
    </li>
    <li>
        编辑话题
    </li>
</ol>
<script>
    function onsubmitForm() {
        var talk_title = $("input[name='talk_title']").val();
        if (talk_title == null || talk_title == "") {
            alert("请填写话题标题");
            $("input[name='talk_title']").focus();
            return false;
        }

        var talk_content = $("textarea[name='talk_content']").val();
        if (talk_content == null || talk_content == "") {
            alert("请填写话题内容");
            $("textarea[name='talk_content']").focus();
            return false;
        }

        var oldPic = document.getElementsByClassName('old-pic');
        var oldSize = parseInt(oldPic.length);
        var picture = document.getElementsByName('picture[]');
        var size = parseInt(picture.length);
        if ((oldSize + size) > 3) {
            alert("图片不能超过三张");
            return false;
        }
    }
</script>
<div class="panel panel-default">
    <div class="panel-heading">编辑话题</div>
    <div class="panel-body">
        <form class="form-horizontal" role="form" action="#" method="POST" onsubmit="return onsubmitForm();">
            <!--表单开始-->
            <div class="form-group">
                <label class="col-sm-2 control-label">话题标题</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="talk_title" value="{$talk['talk_title']}" placeholder="动态标题"/>
                    <div class="help-block">请填写话题标题</div>
                </div>
            </div>
            <!--表单结束-->

            <!--表单开始-->
            <div class="form-group">
                <label class="col-sm-2 control-label">话题内容</label>
                <div class="col-sm-8">
                    <textarea class="form-control" rows="5" name="talk_content">{$talk['talk_content']}</textarea>

                    <span class="help-block">请填写话题内容</span>
                </div>
            </div>
            <!--表单结束-->

            <!--表单开始-->
            <div class="form-group">
                <label class="col-sm-2 control-label">是否置顶</label>
                <div class="col-sm-8">

                    <label class="radio-inline">
                        <input type="radio" name="talk_did" id="inlineRadio1" value="1" {if $talk['talk_did']=='1'}checked="checked"{else}{/if}>不置顶
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="talk_did" id="inlineRadio2" value="2" {if $talk['talk_did']=='2'}checked="checked"{else}{/if}>置顶
                    </label>

                    <span class="help-block">置顶情况</span>
                </div>
            </div>
            <!--表单结束-->

            <!--表单开始-->
            <!--<div class="form-group">
                <label class="col-sm-2 control-label">选择会员</label>
                <div class="col-sm-8">

                    <select class="form-control" name="openid">
                        {loop $user $key $user}
                        <option value="{$user['openid']}" {if $user['openid']==$talk['openid']}selected="selected"{else}{/if}>{$user['nickname']}</option>
                        {/loop}
                    </select>

                    <span class="help-block">选择会员</span>
                </div>
            </div>-->
            <!--表单结束-->

            <!--表单开始-->
            {if !empty($picture)}
            <div class="row">
                <div class="col-sm-2"></div>
                <div class="col-sm-8">
                    {loop $picture $key $picture}
                    <a onclick="delcfm()" href="{php echo $this->createWebUrl('talk',array('op'=>'pic_delete','picture_id'=>$picture['picture_id']));}">
                        <img style='width:70px;height:70px;' src="{$_W['attachurl']}{$picture['picture_url']}" class="img-thumbnail old-pic">
                    </a>
                    {/loop}

                    <span class="help-block">点击图片删除</span>

                </div>
            </div>
            {else}{/if}
            <!--表单结束-->

            <!--表单开始-->
            <div class="form-group">
                <label class="col-sm-2 control-label">话题图片</label>
                <div class="col-sm-8">
                    {php echo tpl_form_field_multi_image('picture');}
                    <span class="help-block">话题图片</span>

                </div>
            </div>
            <!--表单结束-->

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input class="btn btn-default" type="submit" name="submit" value="提 交">

                </div>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>
    </div>
</div>
{template 'common/footer'}
